/*
 * @FilePath: /fxfzywpt/src/utils/disasterLossesLegendData.js
 * @Description:
 */
export const disasterLossesLegendData = {
  legendItems1: [
    { label: '0', min: 0, max: 0, color: '#cccccc', stroke: true },
    { label: '0-10', min: 1, max: 10, color: '#67BE00' },
    { label: '10-30', min: 11, max: 30, color: '#9DD800' },
    { label: '30-50', min: 31, max: 50, color: '#DEEE05' },
    { label: '50-100', min: 51, max: 100, color: '#FEDE00' },
    { label: '100-300', min: 101, max: 300, color: '#FF8F02' },
    { label: '300-500', min: 301, max: 500, color: '#FE4A00' },
    { label: '500-700', min: 501, max: 700, color: '#FD0100' },
    { label: '700-1000', min: 701, max: 1000, color: '#D90100' },
    { label: '1000-3000', min: 1001, max: 3000, color: '#AC0100' },
    { label: '3000-10000', min: 3001, max: 10000, color: '#860100' },
    { label: '10000-30000', min: 10001, max: 30000, color: '#610100' },
    { label: '30000-100000', min: 30001, max: 100000, color: '#4B0000' },
    { label: '100000以上', min: 100001, max: Number.MAX_VALUE, color: '#2A0000' },
  ],
  legendItems2: [
    { label: '0-10', min: 0, max: 10, color: '#67BE00' },
    { label: '10-30', min: 11, max: 30, color: '#9DD800' },
    { label: '30-100', min: 31, max: 100, color: '#DEEE05' },
    { label: '100-300', min: 101, max: 300, color: '#FEDE00' },
    { label: '300-1000', min: 301, max: 1000, color: '#FF8F02' },
    { label: '1000-3000', min: 1001, max: 3000, color: '#FE4A00' },
    { label: '3000-10000', min: 3001, max: 10000, color: '#FD0100' },
    { label: '10000-30000', min: 10001, max: 30000, color: '#D90100' },
    { label: '30000以上', min: 30001, max: Number.MAX_VALUE, color: '#AC0100' },
  ],
  legendItems3: [
    { label: '0-100', min: 0, max: 100, color: '#67BE00' },
    { label: '100-1000', min: 101, max: 1000, color: '#9DD800' },
    { label: '1000-5000', min: 1001, max: 5000, color: '#DEEE05' },
    { label: '5000-10000', min: 5001, max: 10000, color: '#FEDE00' },
    { label: '10000-50000', min: 10001, max: 50000, color: '#FF8F02' },
    { label: '50000-100000', min: 50001, max: 100000, color: '#FE4A00' },
    { label: '100000-300000', min: 100001, max: 300000, color: '#FD0100' },
    { label: '300000以上', min: 300000, max: Number.MAX_VALUE, color: '#D90100' },
  ],
  legendItems4: [
    { label: '0-100', min: 0, max: 100, color: '#67BE00' },
    { label: '100-1000', min: 101, max: 1000, color: '#9DD800' },
    { label: '1000-5000', min: 1001, max: 5000, color: '#DEEE05' },
    { label: '5000-10000', min: 5001, max: 10000, color: '#FEDE00' },
    { label: '10000-50000', min: 10001, max: 50000, color: '#FF8F02' },
    { label: '50000-100000', min: 50001, max: 100000, color: '#FE4A00' },
    { label: '100000-200000', min: 100001, max: 200000, color: '#FD0100' },
    { label: '200000以上', min: 200000, max: Number.MAX_VALUE, color: '#D90100' },
  ],
  legendItems5: [
    { label: '0-50', min: 0, max: 50, color: '#67BE00' },
    { label: '50-100', min: 51, max: 100, color: '#9DD800' },
    { label: '100-500', min: 101, max: 500, color: '#DEEE05' },
    { label: '500-1000', min: 501, max: 1000, color: '#FEDE00' },
    { label: '1000-5000', min: 1001, max: 5000, color: '#FF8F02' },
    { label: '5000-10000', min: 5000, max: 10000, color: '#FE4A00' },
    { label: '10000-50000', min: 10000, max: 50000, color: '#FD0100' },
    { label: '50000-100000', min: 50001, max: 100000, color: '#D90100' },
    { label: '100000-500000', min: 100001, max: 500000, color: '#AC0100' },
    { label: '500000-1000000', min: 500001, max: 1000000, color: '#860100' },
    { label: '1000000-5000000', min: 1000001, max: 5000000, color: '#610100' },
    { label: '5000000-10000000', min: 5000001, max: 10000000, color: '#4B0000' },
    { label: '10000000以上', min: 10000001, max: Number.MAX_VALUE, color: '#2A0000' },
  ],
};
export function findColorIndex(arr, number) {
  const index = arr.findIndex((range) => number >= range.min && number <= range.max);
  return index;
}
export function changeLegendData(parms) {
  let data = parms.result;
  let subTitle = '';
  let legendItems = [];
  let colors = [];
  if (!data)
    return {
      subTitle: '预估死亡人数',
      legendItems: disasterLossesLegendData.legendItems1,
      colors: disasterLossesLegendData.legendItems1.map((item) => item.color),
    };
  switch (data) {
    case 1:
      subTitle = '预估死亡人数';
      legendItems = disasterLossesLegendData.legendItems1;
      colors = disasterLossesLegendData.legendItems1.map((item) => item.color);
      break;
    case 2:
      subTitle = '预估受伤人数';
      legendItems = disasterLossesLegendData.legendItems2;
      colors = disasterLossesLegendData.legendItems2.map((item) => item.color);
      break;
    case 3:
      subTitle = '预估救灾帐篷';
      legendItems = disasterLossesLegendData.legendItems3;
      colors = disasterLossesLegendData.legendItems3.map((item) => item.color);
      break;
    case 4:
      subTitle = '预估救灾队伍';
      legendItems = disasterLossesLegendData.legendItems4;
      colors = disasterLossesLegendData.legendItems4.map((item) => item.color);
      break;
    case 5:
      subTitle = '预估需紧急安置人员';
      legendItems = disasterLossesLegendData.legendItems5;
      colors = disasterLossesLegendData.legendItems5.map((item) => item.color);
      break;
    default:
      subTitle = '预估死亡人数';
      legendItems = disasterLossesLegendData.legendItems1;
      colors = disasterLossesLegendData.legendItems1.map((item) => item.color);
      break;
  }
  return { subTitle, legendItems, colors };
}
